<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<#include "/common/plateform/include/common-base.ftl">
  <title>规则配置管理</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

	<!-- top start -->
	<#include "/common/plateform/top.ftl">
	<!-- top end -->
	<!-- left start -->
	<#include "/common/plateform/left-project.ftl">
	<!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
			<div class="box box-info">
				<!--搜索title  start -->
				<div class="box-header with-border">
					<h3 class="box-title"><i class="fa fa-search"></i> 规则配置管理</h3>
					<div class="box-tools pull-right">
						<button type="button" class="btn btn-box-tool"
								data-widget="collapse"><i class="fa fa-minus"></i>
						</button>
						<button type="button" class="btn btn-box-tool" data-widget="remove">
							<i class="fa fa-times"></i></button>
					</div>
				</div>
				<!--搜索title  end -->

				<div class="box-body">
					<input type="" value="${r'\${[^\{\}]+\}'}" id="rulesPattern"/>
					<form id="searchForm" class="form-horizontal">
						<input type="hidden" name="doCode" value="dymicSql"/>
						<input type="hidden" name="pageName" value="sysRulesProd-list">
						<input type="hidden" name="formName" value="searchForm">
						<input type="hidden" name="sysRulesProd.w_delStatus" value="F">
						<input type="hidden" name="sysRulesProd.w_cateId" value="">
						<input type="hidden" name="orderBy" value="rules_no,order_no"/>
						<input type="hidden" name="ParamType" value="json"/>
						<input type="" name="sysRulesProd.wi_sysName" class="search_sysName" value=""/>

						<div class="col-sm-2 text_r"><label class="control-label">
								规则编号：</label></div>
						<div class="col-sm-2">
							<input type="text" name="sysRulesProd.wl_rulesNo"
								   class="form-control clean" value=""/>
						</div>
						<div class="col-sm-2 text_r"><label
									class="control-label">品种名称：</label></div>
						<div class="col-sm-2">
							<input type="text" class="form-control" readonly="readonly"
								   value=""/>
						</div>
						<div class="col-sm-2 text_r"><label class="control-label">
								品种代码：</label></div>
						<div class="col-sm-2">
							<input type="text" class="form-control" readonly="readonly"
								   value=""/>
						</div>
						<center>
							<center>
								<div class="col-sm-12 box-footer clearfix">
									<button class="btn btn-success" type="button"
											onclick="getTableData();">
										<i class="fa fa-edit-circle"></i>
										查询
									</button>
									<button class="btn btn-warning" type="button"
											onclick="cleanData('searchForm');">重置
									</button>
								</div>
							</center>
					</form>
				</div>
			</div>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
			<div class="box box-success">
				<!--列表title  start -->
				<div class="box-header with-border">
					<h3 class="box-title"><i class="fa fa-user"></i> 规则配置列表
						　　　
						<button onclick="toAddSysRulesData();" class="btn btn-success"
								type="button"><i class="fa fa-plus-circle"></i> 添加规则
						</button>
					</h3>
					<div class="box-tools pull-right">
						　　　　　　　　
						<button type="button" class="btn btn-box-tool"
								data-widget="collapse"><i class="fa fa-minus"></i>
						</button>
						<button type="button" class="btn btn-box-tool" data-widget="remove">
							<i class="fa fa-times"></i></button>
					</div>
				</div>
				<!--列表title  end -->
				<div class="box-body">
					<table id="dataList" class="table table-bordered table-hover">
						<thead class="bg-success">
						<tr>
							<th>规则类型</th>
							<th>排序/规则编号/规则名称/公式名称/公式类型</th>
							<th>可输入/参数单位</th>
							<th>操作</th>
						</tr>
						</thead>
						<tbody id="dataList-body">
						</tbody>
					</table>
					<center>
						<ul id="dataList-page"></ul>
					</center>
				</div>
			</div>
        <!------- 列表 end -------->
        </div>
      </div>

		<div class="modal fade" id="my_modal_add" tabindex="-1" role="dialog"
			 aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog" style="width:1000px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">选择规则</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="sysRulesTemplate-searchForm">
							<input type="hidden" name="pageName" value="sysRulesTemplate-list"/>
							<input type="hidden" name="formName" value="searchForm"/>
							<input type="" name="sysRulesTemplate.wi_sysName" class="search_sysName" value=""/>
							<input type="hidden" name="sysRulesTemplate.w_delStatus" value="F"/>
							<input type="hidden" name="orderBy" value="sysRulesTemplate.rules_type,sysRulesTemplate.rules_no,sysRulesTemplate.order_no"/>
							<div class="form-group">
								<div class="col-sm-2 text_r"><label
											class="control-label">公式名称：</label></div>
								<div class="col-sm-2">
									<input type="text" class="form-control clean"
										   name="sysRulesTemplate.wl_formulaName" value=""
										   id="formulaName"/>
								</div>
								<div class="col-sm-2 text_r"><label
											class="control-label">规则编号：</label></div>
								<div class="col-sm-2">
									<input type="text" class="form-control clean"
										   name="sysRulesTemplate.wl_rulesNo" value=""
										   id="rulesNo"/>
								</div>
								<div class="col-sm-4">
									<button type="button" class="btn btn-success"
											onclick="getSysRulesData();">查询
									</button>
									<button type="button" class="btn btn-warning"
											onclick="FormUtil.cleanData('sysRulesTemplate-searchForm');">
										重置
									</button>
								</div>
							</div>

						</form>
						<table class="table table-bordered table-hover">
							<thead class="bg-success">
							<tr>
								<th>规则类型</th>
								<th>排序/规则编号/规则名称/公式名称/公式类型</th>
								<th>可输入/参数单位/验证/填写提示/操作</th>
							</tr>
							</thead>
							<tbody id="sysRulesTemplate-body">
							</tbody>
						</table>
						<center>
							<ul id="sysRulesTemplate-page"></ul>
						</center>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
		</div>

		<div class="modal fade" id="my_modal_edit" tabindex="-1" data-backdrop="static"
			 data-keyboard="false" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red"> 参数设置 | -<span
										data-name="sysRulesProd.formulaDesc"></span></font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="sysVariable_searchForm">
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" name="modelTypes" value="s_sysVariable"/>
							<input type="hidden" id="formToken" name="formToken">

							<input type="hidden" class="clean"
								   id="sysVariable_sysRulesProd_rulesParamId"
								   data-name="sysRulesProd.rulesParamId"
								   name="sysVariable.w_rulesParamId" value=""/>

							<div class="box-body">
								<!-- Custom Tabs -->
								<div class="form-group">
									<label class="col-sm-2 control-label">描述</label>
									<div class="col-sm-8">
										<span data-name="sysRulesProd.formulaDesc"></span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">公式</label>
									<div class="col-sm-8">
                                        <span id="span_param_formulaSrc"
											  data-name="sysRulesProd.formulaSrc"></span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">结果</label>
									<div class="col-sm-8">
										<input id="txt_param_formulaCal"
											   data-name="sysRulesProd.formulaCal"
											   readonly="readonly" class="form-control clean"/>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-12">
										<table class="table table-bordered table-hover">
											<thead class="bg-warning">
											<tr>
												<th>参数key</th>
												<th>参数value</th>
												<th>操作</th>
											</tr>
											</thead>
											<tbody id="sysVariable-body">
											</tbody>
										</table>
									</div>
								</div>
								<!-- nav-tabs-custom -->
							</div>
							<div class="box-footer">
								<button type="button" class="btn btn-success pull-center btn-lg"
										onclick="saveAllRules();"> 设置完成
								</button>
							</div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
		</div>

		<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog"
			 aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="viewForm">
							<div class="box-body">
								<!-- Custom Tabs -->
								<div class="nav-tabs-custom">
									<div class="tab-content">
										<div class="tab-pane active" id="tab_1">

											<div class="form-group">
												<label class="col-sm-2 control-label">公式算法</label>
												<div class="col-sm-8">
													<span data-name="sysRulesProd.formulaCal"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">公式名称</label>
												<div class="col-sm-8">
													<span data-name="sysRulesProd.formulaName"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">品种编号</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.cateNo"></span>
												</div>
												<label class="col-sm-2 control-label">品种名称</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.cateName"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">规则编号</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.rulesNo"></span>
												</div>
												<label class="col-sm-2 control-label">规则名称</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.rulesName"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">触发状态</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.constantStatus"></span>
												</div>
												<label class="col-sm-2 control-label">节点类型</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.constantType"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">处理方式</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.dealType"></span>
												</div>
												<label class="col-sm-2 control-label">排序</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.orderNo"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">是否可输入</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.showFlag"></span>
												</div>
												<label class="col-sm-2 control-label">创建时间</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.createTime"></span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-sm-2 control-label">输入校验规则</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.showValid"></span>
												</div>
												<label class="col-sm-2 control-label">输入校验说明</label>
												<div class="col-sm-4">
													<span data-name="sysRulesProd.showTip"></span>
												</div>
											</div>

										</div>
										<!-- /.tab-pane -->
									</div>
									<!-- /.tab-content -->
								</div>
								<!-- nav-tabs-custom -->
							</div>
							<div class="box-footer">
								<button type="button" class="btn btn-success pull-right"
										onclick="cannel('view');">关闭
								</button>
							</div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
		</div>

		<!-- 以下是template列表模板的模块区域 -->
		<script type="text/template" id="dataList-template">
			<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=(i+1)?>.<?=strUtil.doNull(rows[i].sysRulesProd.rulesType,'')?></td>
				<td>
					<div class="form-group"><?=rows[i].sysRulesProd.orderNo+'-'+rows[i].sysRulesProd.rulesNo?>
						| <?=strUtil.doNull(rows[i].sysRulesProd.rulesName,'')?>
						|
						<font class="fx7"><?=strUtil.doNull(rows[i].sysRulesProd.formulaName,'')?></font>
						| <font class="fx8">(<?=rows[i].sysRulesProd.dealType?>)</font>
					</div>
					<div class="form-group fx12"><?=strUtil.doNull(rows[i].sysRulesProd.formulaCal,'')?></div>
				</td>
				<td><?=strUtil.doNull(rows[i].sysRulesProd.showFlag,'')?>  <?=strUtil.doNull(rows[i].sysRulesProd.paramUnit,'')?></td>
				<td>
					<button type="button" class="btn btn-success btn-xs"
							onclick="toLoad('<?=rows[i].sysRulesProd.rulesParamId?>','view')">查看
					</button>
					  
					<button type="button" class="btn btn-warning btn-xs"
							onclick="toLoad('<?=rows[i].sysRulesProd.rulesParamId?>','edit');">设置常量
					</button>
					  
					<button type="button" class="btn btn-danger btn-xs"
							onclick="toDele('<?=rows[i].sysRulesProd.rulesParamId?>');">删除
					</button>
				</td>
			</tr>
			<?}?>
		</script>

		<script type="text/template" id="sysRulesTemplate-template">
			<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=(i+1)?>.<?=strUtil.doNull(rows[i].sysRulesTemplate.rulesType,'')?></td>
				<td>
					<div class="form-group"><?=rows[i].sysRulesTemplate.orderNo+'-'+rows[i].sysRulesTemplate.rulesNo?>
						| <?=strUtil.doNull(rows[i].sysRulesTemplate.rulesName,'')?>
						| <?=strUtil.doNull(rows[i].sysRulesTemplate.formulaName,'')?>
						| <?=rows[i].sysRulesTemplate.dealType?>
					</div>
					<div class="form-group fx9"><i
								class="fa fa-info-circle"></i> <?=strUtil.doNull(rows[i].sysRulesTemplate.formulaDesc,'')?>
					</div>
					<div class="form-group fx5"><?=strUtil.doNull(rows[i].sysRulesTemplate.formulaCal,'')?></div>
				</td>
				<td>
					<form id="addFormRule_<?=rows[i].sysRulesTemplate.rulesId?>">
						<input type="hidden" name="pageName" value="sysRulesProd-list"/>
						<input type="hidden" name="formName" value="addForm"/>
						<input type="hidden" name="sysRulesProd.cateId" value=""/>
						<input type="hidden" name="sysRulesProd.cateNo" value=""/>
						<input type="hidden" name="sysRulesProd.cateName" value=""/>
						<input type="hidden" name="sysRulesProd.sysName" value="<?=rows[i].sysRulesTemplate.sysName?>"/>
						<input type="hidden" name="sysRulesProd.formulaCal" value="<?=rows[i].sysRulesTemplate.formulaCal ?>"/>
						<input type="hidden" name="sysRulesProd.formulaSrc" value="<?=rows[i].sysRulesTemplate.formulaCal ?>"/>
						<input type="hidden" name="sysRulesProd.formulaDesc" value="<?=rows[i].sysRulesTemplate.formulaDesc ?>"/>
						<input type="hidden" name="sysRulesProd.formulaName" value="<?=rows[i].sysRulesTemplate.formulaName?>"/>
						<input type="hidden" name="sysRulesProd.paramName" value="<?=rows[i].sysRulesTemplate.formulaName?>"/>
						<input type="hidden" name="sysRulesProd.formulaNo" value="<?=rows[i].sysRulesTemplate.formulaNo?>"/>
						<input type="hidden" name="sysRulesProd.rulesId" value="<?=rows[i].sysRulesTemplate.rulesId?>"/>
						<input type="hidden" name="sysRulesProd.rulesNo" value="<?=rows[i].sysRulesTemplate.rulesNo?>"/>
						<input type="hidden" name="sysRulesProd.rulesName" value="<?=rows[i].sysRulesTemplate.rulesName?>"/>
						<input type="hidden" name="sysRulesProd.rulesType" value="<?=rows[i].sysRulesTemplate.rulesType?>"/>
						<input type="hidden" name="sysRulesProd.dealType" value="<?=rows[i].sysRulesTemplate.dealType?>"/>
						<input type="hidden" name="sysRulesProd.constantType" value="<?=rows[i].sysRulesTemplate.nodeType?>"/>
						<input type="hidden" name="sysRulesProd.constantStatus" value="<?=rows[i].sysRulesTemplate.nodeStatus?>"/>
						<input type="hidden" name="sysRulesProd.orderNo" value="<?=rows[i].sysRulesTemplate.orderNo?>"/>

						<div class="form-group">
							<input type="radio" name="sysRulesProd.showFlag" value="T" checked/> 是
							<input type="radio" name="sysRulesProd.showFlag" value="F"/> 否
							&nbsp;
							<select name="sysRulesProd.paramUnit">
								<option value="">--单位--</option>
								<option value="%">%</option>
								<option value="天">天</option>
							</select>&nbsp;&nbsp;
							<select name="sysRulesProd.showValid">
								<option value="">--选择输入验证--</option>
								<option value="^(100|[1-9]\d|\d)$">0-100的整数</option>
								<option value="^\+?[1-9]\d*$">大于0的整数</option>
								<option value="^\+?[0-9]\d*$">大于或等于0的整数</option>
								<option value="^(([1-9]+)|([0-9]+\.[0-9]{1,2}))$">大于0的保留两位小数
								</option>
								<option value="^([1]?[0-9]|2[0-3]):[0-5][0-9]-([1]?[0-9]|2[0-3]):[0-5][0-9]$">
									时间9:00-11:00
								</option>
							</select>
						</div>
						<div class="form-group">
							<div class="col-sm-8">
								输入提示：<input type="text" class="form-control"
											name="sysRulesProd.showTip"/>
							</div>
							<div class="col-sm-5" style="display:none;">
								缺省：<input type="text" class="form-control"
										  name="sysRulesProd.paramNo"/>
							</div>
						</div>
						<div class="form-group pull-right">
							<button type="button" class="btn btn-danger btn-sm"
									onclick="addRulesItem('addFormRule_<?=rows[i].sysRulesTemplate.rulesId?>','','<?=rows[i].sysRulesTemplate.rulesNo?>','<?=rows[i].sysRulesTemplate.formulaCal?>');">
								选中
							</button>
						</div>
					</form>
				</td>
			</tr>
			<?}?>
		</script>

		<script type="text/template" id="sysVariable-template">
			<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=rows[i].paramKey?></td>
				<td><input id="variableTxt-<?=rows[i].infoId?>" onblur="fullRulesCal()"
						   mvar="<?=rows[i].paramKey?>"
						   name="sysVariable-formulaCal-<?=rows[i].rulesParamId?>"
						   class="form-control sysVariablefcal"
						   value="<?=strUtil.doNull(rows[i].paramValue,'')?>"/></td>
				<td>
					<button type="button" class="btn btn-warning btn-xs"
							onclick="saveVariable('variableTxt-<?=rows[i].infoId?>','<?=rows[i].infoId?>');">
						保存设置
					</button>
					  
				</td>
			</tr>
			<?}?>
		</script>


		<!-- 以下是js模块区域 -->
		<script>
			var clickMenu = "sysRulesProd-list";
			var id, myPage, dataListId, searchFormId, isShowLog, tableSort, tableId;
			myPage = 20;
			dataListId = "dataList";
			searchFormId = "searchForm";
			tableSort = "sysRulesProd";
			tableId = "rulesParamId";
			isShowLog = true;
			var defSysEname = strUtil.doNull(strUtil.getLocalStorage("sysEname"), "");
			if(defSysEname=='plateform'){
				$(".search_sysName").val('');
			}else{
				$(".search_sysName").val(defSysEname);
			}

			$(function () {
				//1、加载分页列表数据
				getTableData();
				//2、控制是否启用token
				//setToken();

				//请在下面补充其他初始化方法（如数据字典、页面加载数据等）

			});

			//读取（查询、编辑）数据
			function toLoad(id, type) {
				//var paramLoadData = {"sysRulesProd.w_rulesParamId":id,"modelTypes":"s_"+tableSort};
				var paramLoadData = {
					"sysRulesProd.w_rulesParamId": id,
					"pageName": "sysRulesProd-list",
					"formName": "searchForm"
				};
				loadObj(type, paramLoadData);
			}

			function toDele(id) {
				var index_submit = layer.confirm('您确定要删除信息吗？', {
							btn: ['Yes', 'No'],
							closeBtn: 0,
							offset: '220px'
						}
						, function () {
							layer.close(index_submit);
							var paramLoadData = {
								"modelTypes": "d_sysRulesProd",
								"sysRulesProd.w_rulesParamId": id
							};
							//var paramLoadData = {"modelTypes":"u_sysRulesProd","sysRulesProd.delStatus":"T","sysRulesProd.w_rulesParamId":id};
							doDele(paramLoadData);
						});
			}

			//反显数据
			function showData(type, myData) {
				console.log(myData);
				if ("view" == type) {
					FormUtil.loadView("sysRulesProd", myData.sysRulesProd);
					$("#my_modal_view").modal("show");
				} else if ("edit" == type) {
					cleanData("sysVariable_searchForm");
					FormUtil.loadView("sysRulesProd", myData.sysRulesProd);
					$("#my_modal_edit").modal("show");
					getVariableData();
				}
			}

			$(function () {
				$('#' + dataListId + ' tbody').on('click', 'tr', function (e) {
					if ($(this).hasClass('selected')) {
						//$(this).removeClass('selected');
					}
					else {
						$('tr.selected').removeClass('selected');
						$(this).addClass('selected');
					}
					id = $('tr.selected td').eq(0).html();
					//  console.log($('tr.selected td').eq(1).html())
				});


			});

			//加载列表数据
			function getTableData() {
				$.ajax({
					type: 'get',
					url: common_list_url,
					data: $("#" + searchFormId).serialize() + getCurrentPage(common_list_url + "?" + $("#" + searchFormId).serialize(), myPage),
					dataType: 'json',
					success: function (myData) {
						console.log(myData);
						var data = baidu.template(dataListId + "-template", eval(myData));
						$("#" + dataListId + "-body").html(data);
						var option = {
							ele: $("#" + dataListId + "-page")[0],
							total: myData.total,
							fn: getTableData,
							url: common_list_url + "?" + $("#" + searchFormId).serialize()
						}
						generatePages(option);
					}
				});
			}

			//打开添加规则页面
			function toAddSysRulesData() {
				cleanData('sysRulesTemplate-searchForm');//清空模态窗口内数据
				getSysRulesData();
				$('#my_modal_add').modal('show');
			}

			//验证此品种是否存在重复规则。
			function checkRulesList(cateNo, rulesNo) {
				var f = false;
				$.ajax({
					type: "get",
					url: common_list_url,
					data: {
						"pageName": "sysRulesProd-list",
						"formName": "searchForm",
						// "sysRulesProd.w_cateNo": cateNo,
						"sysRulesProd.w_sysName": defSysEname,
						"sysRulesProd.w_rulesNo": rulesNo
					},
					dataType: "json",
					async: false,
					success: function (myData) {
						console.log(myData);
						if (myData.flag == "T" && myData.total > 0) {
							f = true;
						}
					}
				});
				return f;
			}

			//添加规则定义
			function addRulesItem(formId, cateNo, rulesNo, formulaCal) {
				var f = checkRulesList(cateNo, rulesNo);

				var index_load = layer.msg("数据正在保存中。。。", {shade: false, offset: '220px'});
				if (!f) {
					$.ajax({
						type: "post",
						url: common_submit_url,
						data: $("#" + formId).serialize(),
						dataType: "json",
						success: function (myData) {
							console.log(myData);
							if (myData.flag == "T") {
								//addRulesItemChild(myData.ids.sysRulesProd_rulesParamId, formulaCal, index_load);
								getTableData();
								layer.close(index_load);
							} else {
								layer.alert(myData.msg);
							}
						}
					});
				} else {
					layer.alert("此规则["+rulesNo+"]已经存在！" + rulesNo + "”");
				}
			}

			//添加规则变量
			function addRulesItemChild(rulesParamId, formulaCal, index_load) {
				//按照正则解析其中变量，分割出输入文本框
				//按照正则匹配：
				var regex = new RegExp(document.getElementById("rulesPattern").value, "g");
				var result = formulaCal.match(regex);
				if (null == result || 0 == result.length) {
					layer.alert("添加规则成功！");
					layer.close(index_load);
					return false;
				}
				layer.alert("此规则存在常量,请单独设置!");
				var strResult = "";
				for (var i = 0; i < result.length; ++i) {
					var paramKey = result[i];
					$.ajax({
						type: "post",
						url: common_submit_url,
						data: {
							"doCode": "dymicSql",
							"modelTypes": "i_sysVariable",
							"sysVariable.rulesParamId": rulesParamId,
							"sysVariable.paramKey": paramKey
						},
						dataType: "json",
						async: false,
						success: function (myData) {
							if (i == (result.length - 1)) {
								layer.close(index_load);
							}
						}
					});
				}
			}

			//加载系统级别规则列表
			function getSysRulesData() {
				//去除搜索空格
				$("#formulaName").val($("#formulaName").val().trim());
				$("#rulesNo").val($("#rulesNo").val().trim());

				var dataListId2 = "sysRulesTemplate";
				var searchForm2 = "sysRulesTemplate-searchForm";
				deleteAllRow(dataListId2);
				$.ajax({
					type: 'get',
					url: common_list_url,
					data: $("#" + searchForm2).serialize() + getCurrentPage(common_list_url + "?" + $("#" + searchForm2).serialize(), 10),
					dataType: 'json',
					success: function (myData) {
						if (isShowLog) console.log(myData);
						var data = baidu.template(dataListId2 + "-template", eval(myData));
						$("#" + dataListId2 + "-body").html(data);
						var option = {
							ele: $("#" + dataListId2 + "-page")[0],
							total: myData.total,
							fn: getSysRulesData,
							url: common_list_url + "?" + $("#" + searchForm2).serialize()
						}
						generatePages(option);
					}
				});
			}

			//加载系统品种具体规则元素列表
			function getVariableData() {
				var dataListId3 = "sysVariable";
				var searchForm3 = "sysVariable_searchForm";
				deleteAllRow(dataListId3);
				$.ajax({
					type: 'get',
					url: common_list_url,
					data: $("#" + searchForm3).serialize(),
					dataType: 'json',
					success: function (myData) {
						if (isShowLog) console.log(myData);
						var data = baidu.template(dataListId3 + "-template", eval(myData));
						$("#" + dataListId3 + "-body").html(data);
					}
				});
			}

			function saveVariable(txtId, infoId) {
				var paramVal = $("#" + txtId).val();
				if (strUtil.isNull(paramVal)) {
					layer.tips("请输入参数" + $("#" + txtId).attr("mvar") + "的值", '#' + txtId, {tips: 3});
					$("#" + txtId).focus();
					return;
				}
				var paramData = {
					"modelTypes": "u_sysVariable",
					"sysVariable.paramValue": paramVal,
					"sysVariable.w_infoId": infoId
				};
				$.ajax({
					type: "post",
					url: common_submit_url + "?doCode=dymicSql",
					data: paramData,
					dataType: "json",
					success: function (myData) {
						var result = myData.flag;
						if (result == "T") {
							layer.tips("保存成功", '#' + txtId, {tips: [3, '#008d4c']});
						}
					}
				});
			}


			//保存设置完成
			function saveAllRules() {
				var size = $(".sysVariablefcal").length;
				var l = 0;
				$(".sysVariablefcal").each(function (i) {
					if (strUtil.isNull($(this).val())) {
						var txtId = $(this).attr("id");
						layer.tips("请输入参数" + $(this).attr("mvar") + "的值", '#' + txtId, {tips: 3});
						$("#" + txtId).focus();
						return false;
					}
					l = (i + 1);
				});
				//alert(size+"-"+l);
				if (l < size) return;

				var index_submit = layer.confirm('您确定要提交信息吗？', {
							btn: ['Yes', 'No'],
							closeBtn: 0,
							offset: '220px'
						}
						, function () {

							var srrparamId = $("#sysVariable_sysRulesProd_rulesParamId").val();
							var sour = $("#txt_param_formulaCal").val();

							layer.close(index_submit);
							var index_load = layer.load(2, {shade: false, offset: '220px'});
							var paramData = {
								"modelTypes": "u_sysRulesProd",
								"sysRulesProd.formulaCal": sour,
								"sysRulesProd.w_rulesParamId": srrparamId
							};
							$.ajax({
								type: "post",
								url: common_submit_url + "?doCode=dymicSql",
								data: paramData,
								dataType: "json",
								success: function (myData) {
									var result = myData.flag;
									if (result == "T") {
										layer.alert("保存设置成功");
										layer.close(index_load);
										$('#my_modal_edit').modal('hide');
									}
								}
							});
						}, function () {
						});


			}

			//替换变量合并参数值，实时显示结果
			function fullRulesCal() {
				var srrparamId = $("#sysVariable_sysRulesProd_rulesParamId").val();
				var sour = $("#span_param_formulaSrc").attr("data-val");
				$("input[name='sysVariable-formulaCal-" + srrparamId + "'").each(function () {
					var key = $(this).attr("mvar");
					var val = $(this).val();
					//alert(key+"-"+val);
					if (val) {
						sour = sour.replace(key, val);
					}
				});
				$("#txt_param_formulaCal").val(sour);
			}


			//设置模态框隐藏事件
			$('#my_modal_add').on('show.bs.modal', function (e) {
				$.ajax({
					type: 'get',
					url: '${ctx}/sendPage/token?token=true',
					dataType: 'json',
					success: function (myData) {
						if (isShowLog) console.log(myData);
						$('#formToken').val(myData);
					}
				});
			});

			//清空数据
			function cleanData(id) {
				$('#' + id).find(".clean").val("");//按照样式清空；
			}

			//打开添加页面
			function toAdd() {
				cleanData('submitFormData');//情况模态窗口内数据
				$("#w_" + tableId).val("");
				$(".datepicker").val("");
				$('#my_modal_add').modal('show');
			}

			//获取对象值
			function loadObj(type, paramData) {
				$.ajax({
					type: 'get',
					url: common_info_url + "?doCode=dymicSql",
					data: paramData,
					async: false,
					dataType: "json",
					success: function (myData) {
						showData(type, myData);
					}
				});
			}

			//删除信息（逻辑删除）
			function doDele(paramData) {
				$.ajax({
					type: "post",
					url: common_submit_url + "?doCode=dymicSql",
					data: paramData,
					dataType: "json",
					success: function (myData) {
						var result = myData.flag;
						if (result == "T") {
							layer.alert("删除操作成功");
							refresh();
						}
					}
				});
			}


			//关闭win
			function cannel(type) {
				if (strUtil.isNull(type)) {
					$('#my_modal_add').modal('hide');
				} else {
					$('#my_modal_' + type).modal('hide');
				}
			}

			function refresh() {
				getTableData();
			}


			function setToken() {
				$.ajax({
					type: 'get',
					url: '${ctx}/sendPage/token?token=true',
					dataType: 'text',
					success: function (myData) {
						console.log(myData);
						$('#formToken').val(myData);
					}
				});
			}

		</script>
    </section>
    <!-- Main end -->
    

  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
	<#include "/common/plateform/foot.ftl">
  <!-- foot start -->
</div>
</body>
</html>




